package launcher;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import com.onpositive.pagerduty.grabber.PagerDutyGrabber;
import com.onpositive.rest.model.Resource;
import com.onpositive.rest.model.printer.ModelPrinter;

public class Launcher {
	
	public static void main(String[] args){
		//http://developer.pagerduty.com/documentation/rest/escalation_policies/escalation_rules
		String inputPath = "D:/RAML/html/Escalation Rules API.htm";
		File f = new File(inputPath);
		if(!f.exists())
			return;
		
		try {						
			Resource res = new PagerDutyGrabber().grabResource("http://developer.pagerduty.com/documentation/rest/schedules");
			File out = new File("D:/RAML/pagerduty_grabbed/schedules.raml");
			if(out.exists())
				out.delete();
			
			out.getParentFile().mkdirs();
			out.createNewFile();
			FileOutputStream fos = new FileOutputStream(out);
			BufferedOutputStream bos = new BufferedOutputStream(fos);
			ModelPrinter.printResource(res, "", bos);
			bos.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
